<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  
  <title>001实施复习 | Hexo</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="前言日志，各位看官就当乐子看吧。 正经人谁写日记啊？！！                                                                                                                                     —-鹅城县长 网络http状态码 状态码的第一位决定了不同的响应状态，有  1">
<meta property="og:type" content="article">
<meta property="og:title" content="001实施复习">
<meta property="og:url" content="http://example.com/2023/03/22/001%E5%AE%9E%E6%96%BD%E5%A4%8D%E4%B9%A0/index.html">
<meta property="og:site_name" content="Hexo">
<meta property="og:description" content="前言日志，各位看官就当乐子看吧。 正经人谁写日记啊？！！                                                                                                                                     —-鹅城县长 网络http状态码 状态码的第一位决定了不同的响应状态，有  1">
<meta property="og:locale" content="en_US">
<meta property="article:published_time" content="2023-03-22T13:42:24.747Z">
<meta property="article:modified_time" content="2023-03-24T09:02:00.726Z">
<meta property="article:author" content="John Doe">
<meta name="twitter:card" content="summary">
  
    <link rel="alternate" href="/atom.xml" title="Hexo" type="application/atom+xml">
  
  
    <link rel="shortcut icon" href="/favicon.png">
  
  
    
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/typeface-source-code-pro@0.0.71/index.min.css">

  
  
<link rel="stylesheet" href="/css/style.css">

  
    
<link rel="stylesheet" href="/fancybox/jquery.fancybox.min.css">

  
<meta name="generator" content="Hexo 6.3.0"></head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">Hexo</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://example.com"></form>
      </div>
    </div>
  </div>
</header>

      <div class="outer">
        <section id="main"><article id="post-001实施复习" class="h-entry article article-type-post" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
  <div class="article-meta">
    <a href="/2023/03/22/001%E5%AE%9E%E6%96%BD%E5%A4%8D%E4%B9%A0/" class="article-date">
  <time class="dt-published" datetime="2023-03-22T13:42:24.747Z" itemprop="datePublished">2023-03-22</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E7%99%BE%E6%97%A5%E5%8D%9A%E5%AE%A2%E8%AE%A1%E5%88%92/">百日博客计划</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="p-name article-title" itemprop="headline name">
      001实施复习
    </h1>
  

      </header>
    
    <div class="e-content article-entry" itemprop="articleBody">
      
        <h1 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h1><p>日志，各位看官就当乐子看吧。</p>
<p><strong>正经人谁写日记啊？！！</strong></p>
<p>                                                                                                                                    —-鹅城县长</p>
<h1 id="网络"><a href="#网络" class="headerlink" title="网络"></a>网络</h1><p><strong>http状态码</strong></p>
<p>状态码的第一位决定了不同的响应状态，有</p>
<ul>
<li><p>1xx 表示消息</p>
</li>
<li><p>2xx 表示成功</p>
</li>
<li><p>3xx 表示重定向</p>
</li>
<li><p>4xx 表示请求错误</p>
</li>
<li><p>5xx 表示服务器错误</p>
</li>
</ul>
<p>常见的有，</p>
<table>
<thead>
<tr>
<th>状态码</th>
<th>含义</th>
</tr>
</thead>
<tbody><tr>
<td>200</td>
<td>请求成功</td>
</tr>
<tr>
<td>403</td>
<td>禁止请求，服务器拒绝请求</td>
</tr>
<tr>
<td>404</td>
<td>未找到，服务器没有找到请求的资源</td>
</tr>
<tr>
<td>500</td>
<td>服务器遇到错误，无法完成请求</td>
</tr>
<tr>
<td>504</td>
<td>网关超时，服务器作为网关或代理，没有及时从上游服务器收到请求</td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</tbody></table>
<p><strong>tcp连接的三次握手和四次挥手</strong></p>
<p>建立<code>tcp</code>连接，需要经过三次握手：</p>
<ol>
<li><p>客户端发送<code>SYN</code>报文给服务器；</p>
</li>
<li><p>服务器响应<code>ack</code>报文给客户端，确认客户端的发送能力；</p>
</li>
<li><p>客户端发送<code>ack</code>报文给服务器。客户端确认服务器的接收和发送能力，服务器确认了客户端的接收能力，然后就能进行数据传输了。</p>
</li>
</ol>
<p><strong>为什么做三次握手，而不是两次？</strong>，第三次握手能够让服务器知道客户端的接收能力是正常的。</p>
<p>断开<code>tcp</code>连接，需要经过四次挥手：</p>
<ol>
<li><p>客户端发送<code>FIN</code>报文，并停止发送数据，向服务器请求断开连接；</p>
</li>
<li><p>服务器发送<code>ack</code>报文响应；</p>
</li>
<li><p>服务器在发送完所有数据后，发送<code>FIN</code>报文，告诉客户端可以断开了；</p>
</li>
<li><p>客户端发送<code>ack</code>报文响应，完成断开。</p>
</li>
</ol>
<p><strong>为什么是四次，不是三次？</strong>，服务器做接收到客户端的断开请求时，有时还有数据需要继续发送，所以不立即发送<code>FIN</code>报文，于是就有了四次挥手。</p>
<p><strong>其他</strong></p>
<p>这部分看了，但是不好记忆，也不好描述：</p>
<ol>
<li><p><code>udp</code>和<code>tcp</code>的对比（udp不可靠）；</p>
</li>
<li><p>http1.0 1.1 2.0</p>
</li>
<li><p>地址栏输入<code>url</code>敲下回车后发生了什么（url解析 -&gt; 域名解析，获得IP -&gt; 建立请求，服务器响应 -&gt; 网站渲染，首先解析dom树，然后css树，然后计算完成大小和位置的布局信息，然后是图像像素信息，最后交给GPU渲染）</p>
</li>
<li><p><code>tcp/IP</code>：指的是一系列互联网协议构成的协议族，模型可分为五层或者四层，五层是应用层、传输层、网络层、数据链路层、物理层。其中还有和<code>OSI</code>模型的对照内容需要了解。</p>
</li>
</ol>
<h1 id="操作系统"><a href="#操作系统" class="headerlink" title="操作系统"></a>操作系统</h1><p><strong>进程和线程</strong></p>
<ol>
<li>线程是进程的子集，每个进程包含多个线程；2. 每个进程有各自独立的内存空间，而所有线程共享一片相同的内存空间；3.每个线程有自己的栈内存存储本地数据。</li>
</ol>
<p><strong>死锁</strong></p>
<p>一个进程请求其他进程拥有的资源，并且不释放自己获取的资源，不断请求，产生死锁。死锁产生条件：1. 互斥：一个资源在同一时间内只能由一个进程获得；2. 请求和保持，一个进程因请求资源而堵塞时，对已获得的资源不释放；3. 不剥夺，进程已获得的资源在未使用完成时，不能剥夺，只能在使用完时自己释放；4. 循环等待，存在循环等待链，每个进程都在等待链中等待下一个进程资源，造成这组进程永远处于等待状态。</p>
<h1 id="服务器"><a href="#服务器" class="headerlink" title="服务器"></a>服务器</h1><h2 id="docker"><a href="#docker" class="headerlink" title="docker"></a>docker</h2><p>docker是软件平台，用于创建、管理、分发应用程序。类似于轻量级的虚拟机，</p>
<p><strong>区别于虚拟机</strong>：不同于虚拟机，容器内只运行应用程序，不是一个完整操作系统。</p>
<p><strong>完整的docker包含那些部分</strong>：client 客户端；daemon 守护进程；images 镜像；container 容器</p>
<p><strong>容器生命周期</strong>：创建create、运行start（run，创建并运行）、停止（stop）启动（start）重启（restart）、杀死（kill，不删除容器，能再次启动）、销毁（destroy，删除，需要重新创建容器）</p>
<p><strong>常用指令</strong>：</p>
<table>
<thead>
<tr>
<th>指令</th>
<th>含义</th>
</tr>
</thead>
<tbody><tr>
<td>docker images</td>
<td>列出本机所有镜像</td>
</tr>
<tr>
<td>docker pull 镜像名[:tag]</td>
<td>下载镜像[对应版本]，名字后加上<code>:</code>接数字，表示下载哪个版本</td>
</tr>
<tr>
<td>docker search</td>
<td>搜索镜像</td>
</tr>
<tr>
<td>docker rmi -f 镜像id</td>
<td>删除镜像</td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</tbody></table>
<p><strong>dockerfile</strong>：存放配置镜像的指令的文件，docker使用dockerfile自动构建镜像。</p>
<h2 id="Nginx"><a href="#Nginx" class="headerlink" title="Nginx"></a>Nginx</h2><p>用于构建web服务器，常用于反向代理。常用功能：1. 反向代理：客户端向服务器发送请求时，首先会经过nginx服务器，nginx将请求分发给相应的web服务器；2. 负载均衡：将大量的前端请求或数据流量分担到后端多个网络节点上分别处理，减少用户等待时间。</p>
<h3 id="负载均衡"><a href="#负载均衡" class="headerlink" title="负载均衡"></a>负载均衡</h3><p>根据不同的实际情况，可采取不同的均衡算法，介绍如下。</p>
<p><strong>普通轮询算法</strong></p>
<figure class="highlight nginx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="section">upstream</span> OrdinaryPolling &#123;</span><br><span class="line">    <span class="attribute">server</span> <span class="number">127.0.0.1:8080</span>;</span><br><span class="line">    <span class="attribute">server</span> <span class="number">127.0.0.1:8081</span>;</span><br><span class="line">&#125;</span><br><span class="line">    <span class="section">server</span> &#123;</span><br><span class="line">        <span class="attribute">listen</span>       <span class="number">80</span>;</span><br><span class="line">        <span class="attribute">server_name</span>  localhost;</span><br><span class="line"></span><br><span class="line">        <span class="section">location</span> / &#123;</span><br><span class="line">            <span class="attribute">proxy_pass</span> http://OrdinaryPolling;</span><br><span class="line">            <span class="attribute">index</span>  index.html index.htm index.jsp;</span><br><span class="line"></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure>

<p>上面代码表明，<code>upstream</code>代码块声明了名为<code>OrdinaryPolling</code>的负载均衡配置，<code>server</code>代码块配置虚拟主机，监听<code>localhost</code>主机上的<code>80</code>端口（端口默认为80），当请求地址为<code>/</code>时，采用反向代理<code>proxy_pass</code>设置的方案，将请求分发给<code>127.0.0.1:8080</code>和<code>8081</code>两个服务器，默认响应<code>index.html</code>文件。</p>
<p><strong>加权轮询算法</strong></p>
<p>当服务器配置不同，希望高配置的服务器处理更多的请求，这时就可以采用<strong>加权轮询</strong>。配置如下，</p>
<figure class="highlight nginx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="section">upstream</span> OrdinaryPolling &#123;</span><br><span class="line">    <span class="attribute">server</span> <span class="number">127.0.0.1:8080</span> weight=<span class="number">5</span>;</span><br><span class="line">    <span class="attribute">server</span> <span class="number">127.0.0.1:8081</span> weight=<span class="number">2</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>此时，nginx会根据权重给不同服务器分担不同的请求量，8080和80801处理的量比例为5:2。不设置<code>weight</code>则默认都是1，就是普通轮询。</p>
<p><strong>基于IP路由负载</strong></p>
<p>当服务器需要保存信息完成验证时，如登录验证时，保存session，当请求在第一个服务器没处理完，通过nginx轮询到第二个服务器上，那么这个服务器是没有会话信息的。又需要重新登录。此时可以采用<code>基于IP负载</code>。配置如下，</p>
<figure class="highlight nginx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="section">upstream</span> OrdinaryPolling &#123;</span><br><span class="line">    ip_hash;</span><br><span class="line">    <span class="attribute">server</span> <span class="number">127.0.0.1:8080</span> weight=<span class="number">5</span>;</span><br><span class="line">    <span class="attribute">server</span> <span class="number">127.0.0.1:8081</span> weight=<span class="number">2</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p><code>upstream</code> 指令块中增加了<code>ip_hash</code> 指令。该指令就是告诉 nginx 服务器，同一个 IP 地址客户端发送的请求都将分发到同一个服务器进行处理.</p>
<p><strong>基于服务器响应时间负载分配</strong></p>
<p>根据服务器响应时间分配，时间越短的优先分配。<code>upstream</code> 指令块中增加了<code>fair</code> 指令.</p>
<p><strong>对不同域名实现负载均衡</strong></p>
<p>结合<code>location</code> 指令块可以实现对不同域名实现负载均衡。配置如下，</p>
<figure class="highlight nginx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="section">upstream</span> wordbackend &#123;</span><br><span class="line">    <span class="attribute">server</span> <span class="number">127.0.0.1:8080</span>;</span><br><span class="line">    <span class="attribute">server</span> <span class="number">127.0.0.1:8081</span>;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="section">upstream</span> pptbackend &#123;</span><br><span class="line">    <span class="attribute">server</span> <span class="number">127.0.0.1:8082</span>;</span><br><span class="line">    <span class="attribute">server</span> <span class="number">127.0.0.1:8083</span>;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="section">server</span> &#123;</span><br><span class="line">        <span class="attribute">listen</span>       <span class="number">80</span>;</span><br><span class="line">        <span class="attribute">server_name</span>  localhost;</span><br><span class="line"></span><br><span class="line">        <span class="section">location</span> /word/ &#123;</span><br><span class="line">            <span class="attribute">proxy_pass</span> http://wordbackend;</span><br><span class="line">            <span class="attribute">index</span>  index.html index.htm index.jsp;</span><br><span class="line"></span><br><span class="line">        &#125;</span><br><span class="line">    <span class="section">location</span> /ppt/ &#123;</span><br><span class="line">            <span class="attribute">proxy_pass</span> http://pptbackend;</span><br><span class="line">            <span class="attribute">index</span>  index.html index.htm index.jsp;</span><br><span class="line"></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure>

<p>当路径为 <code>word</code> 时，会分配到 <code>127.0.0.1:8080</code>和<code>8081</code>上，当路径为 <code>ppt</code> 时，会分配到 <code>8082</code>和<code>8083</code>上。</p>
<h1 id="彩蛋"><a href="#彩蛋" class="headerlink" title="彩蛋"></a>彩蛋</h1><p>为了一个软件实施的岗位做准备，网上关于实施的面试题大多都是计算机通识内容，再结合工作经验，实施中数据库和服务器的技术需要着重关注（还在等面试通知，逆天^,..,.,^）。网络相关的知识点还要没复习到的，也有理解或记不清的内容。还有数据库的知识点。当然服务器也需要再补补</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://example.com/2023/03/22/001%E5%AE%9E%E6%96%BD%E5%A4%8D%E4%B9%A0/" data-id="clfjqowu30000ewaa2udw6kh4" data-title="001实施复习" class="article-share-link">Share</a>
      
      
      
    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/2023/03/22/002%E6%8A%95%E7%AE%80%E5%8E%86%E5%92%8C%E5%88%B7%E9%A2%98/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          002投简历和刷题
        
      </div>
    </a>
  
  
    <a href="/2023/03/22/hello-world/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">Hello World</div>
    </a>
  
</nav>

  
</article>


</section>
        
          <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Categories</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/%E7%99%BE%E6%97%A5%E5%8D%9A%E5%AE%A2%E8%AE%A1%E5%88%92/">百日博客计划</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tags</h3>
    <div class="widget">
      <ul class="tag-list" itemprop="keywords"><li class="tag-list-item"><a class="tag-list-link" href="/tags/ES6/" rel="tag">ES6</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hexo/" rel="tag">hexo</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/uniapp/" rel="tag">uniapp</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%89%8D%E7%AB%AF/" rel="tag">前端</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tag Cloud</h3>
    <div class="widget tagcloud">
      <a href="/tags/ES6/" style="font-size: 10px;">ES6</a> <a href="/tags/hexo/" style="font-size: 10px;">hexo</a> <a href="/tags/uniapp/" style="font-size: 10px;">uniapp</a> <a href="/tags/%E5%89%8D%E7%AB%AF/" style="font-size: 10px;">前端</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2023/03/">March 2023</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2023/03/24/025uniapp-done/">025uniapp-done</a>
          </li>
        
          <li>
            <a href="/2023/03/23/024uniapp%E7%AC%AC%E4%B8%89%E5%A4%A9/">024uniapp第三天</a>
          </li>
        
          <li>
            <a href="/2023/03/22/023gitee-hexo%E6%90%AD%E5%BB%BA%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2/">023gitee+hexo搭建个人博客</a>
          </li>
        
          <li>
            <a href="/2023/03/22/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8MDN%E6%96%87%E6%A1%A3/">(no title)</a>
          </li>
        
          <li>
            <a href="/2023/03/22/%E5%89%8D%E7%AB%AF%E9%9D%A2%E8%AF%95%E9%A2%98/">(no title)</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      
      &copy; 2023 John Doe<br>
      Powered by <a href="https://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>

    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    


<script src="/js/jquery-3.4.1.min.js"></script>



  
<script src="/fancybox/jquery.fancybox.min.js"></script>




<script src="/js/script.js"></script>





  </div>
</body>
</html>